package com.zsy.mapper;

import com.zsy.entity.PurchaseRequisition;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
@Mapper
public interface IPurchaseRequisitionMapper {
    List<PurchaseRequisition> list(@Param("userId") Integer userId,
        @Param("purchaseId") String purchaseId,
        @Param("relevantData") String relevantData,
        @Param("supplier") String supplier);

    @Insert("insert into purchase_requisitions (purchase_id, relevant_data, applicant,apply_time,product_name," +
            "product_number,supplier, purchase_cost, remarks, user_id,is_deleted) " +
            "values (#{purchaseId}, #{relevantData}, #{applicant}, #{applyTime}, #{productName}, " +
            "#{productNumber}, #{supplier}, #{purchaseCost}, #{remarks}, #{userId}, 1)")
    int add(PurchaseRequisition purchaseRequisition);

    @Delete("UPDATE purchase_requisitions SET is_deleted = 0 where purchase_requisitions_id=#{purchaseRequisitionsId}")
    int deleteById(Integer purchaseRequisitionsId);

    int updateById(PurchaseRequisition purchaseRequisition);
}
